//
//  UIView+MJ.m
//  QQZoneDemo
//
//  Created by MJ Lee on 14-5-26.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "UIView+MJ.h"

@implementation UIView (MJ)
- (void)setX:(CGFloat)x
{
    CGRect frame = self.frame;
    frame.origin.x = x;
    self.frame = frame;
}

- (CGFloat)x
{
    return self.frame.origin.x;
}

- (void)setY:(CGFloat)y
{
    CGRect frame = self.frame;
    frame.origin.y = y;
    self.frame = frame;
}

- (CGFloat)y
{
    return self.frame.origin.y;
}

- (void)setWidth:(CGFloat)width
{
    CGRect frame = self.frame;
    frame.size.width = width;
    self.frame = frame;
}

- (CGFloat)width
{
    return self.frame.size.width;
}

- (void)setHeight:(CGFloat)height
{
    CGRect frame = self.frame;
    frame.size.height = height;
    self.frame = frame;
}

- (CGFloat)height
{
    return self.frame.size.height;
}

- (void)setSize:(CGSize)size
{
    CGRect frame = self.frame;
    frame.size = size;
    self.frame = frame;
}

- (CGSize)size
{
    return self.frame.size;
}

- (void)setOrigin:(CGPoint)origin
{
    CGRect frame = self.frame;
    frame.origin = origin;
    self.frame = frame;
}

- (CGPoint)origin
{
    return self.frame.origin;
}

- (void)setCenterX:(CGFloat)centerX
{
    CGPoint center = self.center;
    center.x = centerX;
    self.center = center;
}

- (CGFloat)centerX
{
    return self.center.x;
}

- (void)setCenterY:(CGFloat)centerY
{
    CGPoint center = self.center;
    center.y = centerY;
    self.center = center;
}

- (CGFloat)centerY
{
    return self.center.y;
}


- (CGFloat) top
{
    return self.frame.origin.y;
}

- (void) setTop: (CGFloat) newtop
{
    CGRect newframe = self.frame;
    newframe.origin.y = newtop;
    self.frame = newframe;
}

- (CGFloat) left
{
    return self.frame.origin.x;
}

- (void) setLeft: (CGFloat) newleft
{
    CGRect newframe = self.frame;
    newframe.origin.x = newleft;
    self.frame = newframe;
}

- (CGFloat) bottom
{
    return self.frame.origin.y + self.frame.size.height;
}

- (void) setBottom: (CGFloat) newbottom
{
    CGRect newframe = self.frame;
    newframe.origin.y = newbottom - self.frame.size.height;
    self.frame = newframe;
}

- (CGFloat) right
{
    return self.frame.origin.x + self.frame.size.width;
}

- (void) setRight: (CGFloat) newright
{
    CGFloat delta = newright - (self.frame.origin.x + self.frame.size.width);
    CGRect newframe = self.frame;
    newframe.origin.x += delta ;
    self.frame = newframe;
}
//提示 是否有数据
+ (UIView *)noDataLabel:(NSString *)str
{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 100, UIScreen.mainScreen.bounds.size.width, 30)];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 15, UIScreen.mainScreen.bounds.size.width, 15)];
    label.font = [UIFont systemFontOfSize:14];
    label.textAlignment = NSTextAlignmentCenter;
   // label.textColor = UIColorFromRGB(0X999999);
    label.textColor=[UIColor blackColor];
    label.text = str;
    [view addSubview:label];
    return view;
}

//提示 是否有数据
+ (UIView *)noDataLabel:(NSString *)str color:(UIColor *)color
{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 100, UIScreen.mainScreen.bounds.size.width, 30)];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 15, UIScreen.mainScreen.bounds.size.width, 15)];
    label.font = [UIFont systemFontOfSize:14];
    label.textAlignment = NSTextAlignmentCenter;
    // label.textColor = UIColorFromRGB(0X999999);
    label.textColor=color;
    label.text = str;
    [view addSubview:label];
    return view;
}

/**
 *  没有数据的图片
 */
+ (UIView *)noDataImageName:(NSString *)imageName title:(NSString *)title frame:(CGRect )frame{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height-64-49)];
    view.backgroundColor=[UIColor clearColor];
    UIImageView *imageV=[[UIImageView alloc]init];
    imageV.image=[UIImage imageNamed:imageName];
    imageV.frame=frame;
    [view addSubview:imageV];
    
    CGFloat labelY=CGRectGetMaxY(imageV.frame)+20;
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, labelY, UIScreen.mainScreen.bounds.size.width, 20)];
    label.font = [UIFont systemFontOfSize:17];
    label.textAlignment = NSTextAlignmentCenter;
    if ([imageName isEqualToString:@"noDataBlack"]) {
         label.textColor = [UIColor whiteColor];
    }else{
        label.textColor = UIColor.darkTextColor;
    }
   
    label.text = title;
    [view addSubview:label];
    return view;

    
}

@end
